import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

public class World{
	
	/**
	 * World class members 
	 */
	private HashMap<Integer, Point> points = new HashMap<Integer, Point>();
	private int pointsCount;
	private int edgesCount;
	private ArrayList<Edge> edges = new ArrayList<Edge>();
//	private int centerX;
//	private int centerY;
	
	// ctor
	/*
	public World(int w,int h){
		centerX = w/2;
		centerY = h/2;
	}
	*/

	/**
	 * Function for reading the scene file - and create world according to the input
	 * @param fileName 
	 * @throws IOException
	 */
	public void readScene(String fileName) throws IOException{
		
		BufferedReader in = new BufferedReader(new FileReader(fileName));
		String line = in.readLine();
		//parse the number of point in file
		pointsCount = Integer.parseInt(line);
		//parse the points coordinates - create points map
		for(int i=0;i<pointsCount;i++){
			line = in.readLine();
			String[] pointIdx = line.split(" ");
			Point p = new Point (Integer.parseInt(pointIdx[0]),Integer.parseInt(pointIdx[1]));
			points.put(new Integer(i+1), p);
		}
		line = in.readLine();
		//parse the edge number
		edgesCount = Integer.parseInt(line);
		//parse the edges - create edges list
		for(int i=0;i<edgesCount;i++){
			line = in.readLine();
			String[] pointIdx = line.split(" ");
			int idx1 = Integer.parseInt(pointIdx[0])+1;
			int idx2 = Integer.parseInt(pointIdx[1])+1;
			Edge e = new Edge(points.get(new Integer(idx1)),points.get(new Integer(idx2)),idx1,idx2);
			edges.add(e);
		}
	}

	// getters for class members
	public HashMap<Integer, Point> getPoints() {
		return points;
	}
	public ArrayList<Edge> getEdges() {
		return edges;
	}
	/*
	public int getCenterX() {
		return centerX;
	}
	public int getCenterY() {
		return centerY;
	}
	*/
	public int getPointsCount() {
		return pointsCount;
	}
	public int getEdgesCount() {
		return edgesCount;
	}

}
